package com.example.sqlitetest;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

import java.util.List;

@Dao
public interface AlarmDataDao {

    //插入数据
    @Insert
    void insertAlarmData(AlarmData... alarmData);

    //删除指定数据
    @Delete
    void deleteAlarmData(AlarmData... alarmData);

    //删除全部数据
    @Query("delete from alarmdata")
    void deleteAllAlarmData();

    //根据报警编号和时间范围查询报警值
    @Query("select * from alarmdata where :alarmNumber = alarm_number and time_start between :startTime and :stopTime")
    List<AlarmData> loadAlarmDataByNumberAndTimeStamp(int alarmNumber,int startTime,int stopTime);

    //根据时间范围查询报警值
    @Query("select * from alarmdata where time_start between :startTime and :stopTime")
    List<AlarmData> loadAlarmDataByTimeStamp(int startTime,int stopTime);
}
